package com.ceba.test.webservice.application;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServlet;

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ceba.test.base.configs.CebaConfig;
import com.ceba.test.base.web.response.WebServiceResponseInfo;
import com.ceba.test.webservice.service.RestService;
import com.ceba.test.webservice.service.impl.RestServiceImpl;

@SuppressWarnings("serial")
public class RestApplication extends HttpServlet{ 
	
	static Logger logger = LoggerFactory.getLogger(RestApplication.class);
	
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public  void init(){
    	JAXRSServerFactoryBean restServer = new JAXRSServerFactoryBean();  
    	logger.debug("加载RestService--");
    	List list = new ArrayList();
    	RestService rs = new RestServiceImpl();
    	list.add(rs);
        restServer.setResourceClasses(WebServiceResponseInfo.class);  
        restServer.setServiceBean(rs);
        restServer.setAddress(CebaConfig.cebaWebServiceUrl);  
        restServer.create();  

    }
    
    @Override
	public void destroy() {
		System.exit(0);
	}
}
